﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

public class AppConst
{
    /// <summary>
    /// 默认进游戏时的地图
    /// </summary>
    public const string defaultScene = "WinterScene";

    /// <summary>
    /// cdn地址暂时用本地目录代替
    /// </summary>
	public const string cdnPath = "file:///E:/WinterCDN";   
    //public const string cdnPath = "file:///E:/WinterResource/WinterCDN";
    //public const string cdnPath = "http://172.20.5.77:8080/wintercdn";

    /// <summary>
    /// md5文件信息保存的文件名
    /// </summary>
    public const string Md5ConfigName = "CDNCONFIG.txt";

    
    /// <summary>
    /// 获取CDN MD5信息文件地址
    /// </summary>
    public static string ConfigPath{
        get
        {
            string result =  cdnPath + "/" + Md5ConfigName;
            return PathTool.FormationPath(result);
        }
    }

    /// <summary>
    /// 将该文件路径转成完整CDN路径
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    public static string TransformationCDNPath(string filePath)
    {
        string result = cdnPath + "/" + filePath;
        return PathTool.FormationPath(result);
    }


    public static string GetDataPath(string path)
    {
        return Application.persistentDataPath + "/" + path;
    }


    /// <summary>
    /// 将该文件路径转成应用数据目录
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    public static string TransformationDataPath(string filePath)
    {
        string result = Application.persistentDataPath + "/" + filePath;
        return PathTool.FormationPath(result);
    }

    public static string GetSceneAssetBundlePath(string SceneName)
    {
        return "assetbundle/scene/" + SceneName.ToLower() + "/" + SceneName.ToLower();
    }

    public static string GetActorAssetBundlePath(string actorName)
    {
        return "assetbundle/actor/" + actorName.ToLower();
    }

    public static string GetSkillEffectAssetBundlePath(string effectName)
    {
        return "assetbundle/skilleffect/" + effectName.ToLower();
    }

    public static string AppContentPath()
    {
        string path = string.Empty;
        switch (Application.platform)
        {
            case RuntimePlatform.Android:
                path = "jar:file://" + Application.dataPath + "!/assets/";
                break;
            case RuntimePlatform.IPhonePlayer:
                path = "file://" + Application.dataPath + "/Raw/";
                break;
            default:
                path = "file://" + Application.dataPath + "/StreamingAssets/";
                break;
        }
        return path;
    }

    public static string DataPath
    {
        get
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer ||
                Application.platform == RuntimePlatform.Android)
            {
                return Application.persistentDataPath;
            }else if(Application.platform == RuntimePlatform.WindowsEditor){
                return "file://" + Application.persistentDataPath;
            }
            return Application.persistentDataPath;
        }
    }

}
